<script type="text/javascript">
	function _AddFriendSubmit()
	{
		var addlowaddtheanswer = $.trim($('#addlowaddtheanswer').val());
		if(addlowaddtheanswer=="")
		{
			_Cerror('addlowaddtheanswer',3);
			return;
		}
		var addlowaddtheanswerid = $.trim($('#addlowaddtheanswerid').val());
		var addlowaddyanzheng = $.trim($('#addlowaddyanzheng').val());
		$.ajax({
			  url: "/index.php?r=profile/addfriendsubmit",
			  data: {'addlowaddtheanswerid':addlowaddtheanswerid,'addlowaddtheanswer':addlowaddtheanswer,'addlowaddyanzheng':addlowaddyanzheng},
			  type: 'post',
			  success: function(data){
				  	if(data._code == 1)
				  	{
				  		Boxy.get('.boxyclose').hide();
				  		Boxy.alert("申请已经发送出去，请等待对方回应！", function() {},{title: "提示",unloadOnHide:true,modal:true});
				  	}
					if(data._code == "-1")
					{
						_Cerror('addlowaddtheanswer',3);
						$('#addlowaddtheanswer').val('');
						$('#mini_err').html('答案不正确哦');
						$('#mini_err_div').show();
					}
					if(data._code == -2)
						_Cerror('addlowaddtheanswer',3);
					if(data._code == -3)
					{
						$('#mini_err').html('非法操作哦');
						$('#mini_err_div').show();
					}
			  },
			  dataType: "json"
			});
	}

	function _chooseAnswers(obj)
	{
		var _an_val = $(obj).val();
		$('#addlowaddtheanswerid').val(_an_val);
	}
</script>

<div style="">
    <table style="width: 100%; height: 100%;" class="">
            <tr>
                <td class="pop_content">
                    <div class="dialog_content">
                        <div class="dialog_body">
                            <div class="publisher" id="mini_frame">
                                <div class="user-avatar">
                                    <a href="#" style="cursor: pointer;">
                                        <img src="<?php echo $model->avatar; ?>" width="50" height="50" alt="苏元元">
                                    </a>
                                </div>
                                <div class="status-publisher">
                                    <form style="padding-right: 0px;">
                                    	<textarea name="addlowaddyanzheng" id="addlowaddyanzheng"></textarea>
                                        <div style="overflow: hidden; height: 28px; display: block; width: 350px;" id="mini_tools" class="publisher-footer clearfix">
											加 <a href="#"><font color="#ff3300"><?php echo $model->userprofile->nickname; ?></font></a> 为熟人，需要回答一下问题
                                        </div>
                                    </form>
                                </div>
                            </div>
                            <div style="padding-right: 0px; margin-top: 10px; width: 350px;" id="mini_meta">
                                <p>
                                    <span id="mini_fwd_status">
										我是。
                                    </span>
                                </p>
                                <div id="mini_target">
                                    	<?php if(count($answers) < 2){ ?>
                                    		<?php foreach ($answers as $val){ ?>
												<?php echo $val->question; ?>
			                                    <span id="mini_comment_to_span">
				                                    <input type="hidden" value="<?php echo $val->id; ?>" name="addlowaddtheanswerid" id="addlowaddtheanswerid" >
													<input type="text" value="" name="addlowaddtheanswer" id="addlowaddtheanswer" class="input-text" size="30">*
			                                    </span>
			                                <?php } ?>
			                            <?php } else { ?>
			                            	<select onchange="_chooseAnswers(this)">
				                            <?php foreach ($answers as $key=>$val){ ?>
				                            	<?php if($key == 0) $_hidde_id = $val->id; ?>
				                            	<option value="<?php echo $val->id; ?>"><?php echo $val->question; ?></option>
				                            <?php } ?>
											</select>
		                                    <span id="mini_comment_to_span">
			                                    <input type="hidden" value="<?php echo $_hidde_id; ?>" name="addlowaddtheanswerid" id="addlowaddtheanswerid" >
												<input type="text" value="" name="addlowaddtheanswer" id="addlowaddtheanswer" class="input-text" size="30">*
		                                    </span>
		                                <?php } ?>
                                    <div style="display:none;" id="mini_err_div"><font color="#ff3300" id="mini_err"></font></div>
                                </div>
                            </div>
                        </div>
                        <div class="dialog_buttons">
                            <input value="确定" class=" input-submit" type="button" onclick="_AddFriendSubmit();">
                            <input value="取消" class=" input-submit gray" type="button" onclick="Boxy.get('.boxyclose').hide()">
                        </div>
                    </div>
                </td>
            </tr>
    </table>
</div>